package hash;

/**
 * @author way
 * @create 2025-02-07 12:27
 */
public class _383_canConstruct {
    public boolean canConstruct(String ransomNote, String magazine) {
        if (ransomNote.length()>magazine.length()) return false;

        int[] record = new int[26];

        for (char c : magazine.toCharArray()) {
            record[c-'a']++;
        }

        for (char c : ransomNote.toCharArray()) {
            record[c-'a']--;
        }

        for (int i : record) {
            if (i<0) return false;
        }
        return true;
    }
}
